/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: Jan 29, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.plot.ruler.tick;


import epoviz.trex.common.text.JTextUtils;

import java.awt.*;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;
import java.text.AttributedString;

public class DfLabel extends BasicLabel{

     public  void paintComponent(Graphics2D g2d, String s, Point p, int distance, int loctype){
         //String stv=this.getReadableValue(tickValue,this.ruler.getFormat() );

         AttributedString atts=new AttributedString(s);
        Color lbc=getLabelColor();
        if(lbc!=null){
            atts.addAttribute(TextAttribute.FOREGROUND,lbc);
        }//if lbc ==null, not set, means use ruler's default color
        atts.addAttribute(TextAttribute.FONT,getLabelFont());

        //TextLayout tl = JTextUtils.getPlainTextLayout(s,this.ruler.getLabelFont() ,g2d);
        TextLayout tl = JTextUtils.getAttributedTextLayout(atts,g2d);

        Rectangle2D tb = tl.getBounds();
        Dimension size=new Dimension((int)tb.getWidth() ,(int) tb.getHeight() );
        Point paintp = p;//LabelLocator.getTextPaintOriginal(p,distance,loctype,size);

        tl.draw(g2d, paintp.x , paintp.y);
    }
}
